const app = getApp();
Page({
  data: {
    name: '',
    idNumber: '',
    checked: false,
  },

 
  onAgreementChange(event) {
    this.setData({ checked: event.detail });
  },

  onSubmit() {
    if (this.data.checked === true && this.data.name !== '' && this.data.idNumber !== '') {
      // 提交表单
      let url = app.globalData.URL + '/users/updateById';
      console.log(url);
      let data = {
        userId: app.globalData.user.userId,
        name: this.data.name,
        cardId: this.data.idNumber,
      };
      app.wxRequest('GET', url, data, (res) => {
        console.log("Data submitted:", data);
        if(res.statusCode=="200"){
          wx.showToast({
            title: '提交成功',
            icon: 'none',
          });
        }
      }, (err) => {
        console.log(err.errMsg);
      });
    } else {
      wx.showToast({
        title: '请完整填写信息并同意协议',
        icon: 'none',
      });
    }
  }
});
